import unittest
from base.get_driver import GetDriver
from page.page_login import PageLogin
from page.page_pay import PagePay
from base.get_logger import GetLogger

#获取log日志器
log = GetLogger().get_logger()
class TestPay(unittest.TestCase):
    #setup
    def setUp(self):
        #获取driver
        self.driver = GetDriver().get_driver()
        #登录成功
        PageLogin(self.driver).page_login_success()
        #实例化PagePay类
        self.pay = PagePay(self.driver)
    #teardown
    def tearDown(self):
        #关闭driver
        GetDriver().quit_driver()
    #定义支付测试方法
    def test_pay(self):
        try:
            #调用支付方法
            self.pay.page_pay()
            #断言
            print("msg:",self.pay.page_pay_get_payment_result())
            self.assertIn("订单提交成功",self.pay.page_pay_get_payment_result())
        except Exception as e:
            #截图
            self.pay.base_get_image()
            # 日志
            log.error(e)